package com.lecampus.businessSecond_hand_transactions.controller;


import com.lecampus.businessSecond_hand_transactions.entity.Product;
import com.lecampus.businessSecond_hand_transactions.service.ProductService;
import com.lecampus.businessSecond_hand_transactions.vo.ProductCategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-03-24
 */
@RestController
@RequestMapping("/lecampus/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/findAll")
    public List<ProductCategoryVO> findAll() {
        return productService.findAll();
    }

    @GetMapping("/findByUserId/{userId}")
    public List<ProductCategoryVO> findByUserId(@PathVariable("userId") String userId) {
        return productService.findByUserId(userId);
    }

    @PostMapping("/input")
    public void input(Product product) {
        productService.inputProduct(product);
    }

    @GetMapping("/{productId}/delete")
    public void deleteProduct(@PathVariable("productId") String productId) {
        productService.deleteProductById(productId);
    }
}

